<?php

namespace App\Transformers\web;
use App\Models\User;
use League\Fractal\TransformerAbstract;

class ImTransformer extends TransformerAbstract
{
    /**
     * List of resources to automatically include
     *
     * @var array
     */
    protected $defaultIncludes = [
        //
    ];

    /**
     * List of resources possible to include
     *
     * @var array
     */
    protected $availableIncludes = [
        //
    ];


    public function transform(User $user)
    {
        if (is_object($user)) {
            $data = $user->toArray();
        } else {
            $data = $user;
        }
        if($user->role == 1){
            $user->role = '普通用户';
        }else{
            $user->role = '客服';
        }
    }
}
